package logic

import (
	"context"
	"errors"
	"user_srv/models/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseUpdateLogic {
	return &HouseUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseUpdateLogic) HouseUpdate(in *user.HouseUpdateRequest) (*user.HouseUpdateResponse, error) {
	// todo: add your logic here and delete this line
	house := mysql.House{}
	err := house.HouseUpdateStatus(in.HouseId, in.HouseStatus)
	if err != nil {
		logx.Info("修改房源状态", err)
		return nil, errors.New("修改房源状态")
	}

	return &user.HouseUpdateResponse{}, nil
}
